<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>
<html class="">
<head>
	
	<meta name="author" content="蓝凌科技">
	<meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=no">
	<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
	<meta http-equiv="Pragma" content="no-cache" />
	<meta http-equiv="Expires" content="0" />

	<link rel="stylesheet" type="text/css" href="/Public/Api/css/sm.min.css">	
	<link rel="stylesheet" type="text/css" href="/Public/Api/css/sm-extend.min.css">	
	
	<title>帮工小哥</title>
	
	<script type="text/javascript">
	    var _root = '<?php echo ($_site_url); echo U(' / ');?>', _controller = '<?php echo ($_controller); ?>';
	</script>
	
	
	<link rel="stylesheet" type="text/css" href="/Public/Api/css/order.css">


</head>
<body>
	
	

<!--主页面-->
<div class="page-group">
    <div class="page page-current my-order">
        <nav class="bar bar-tab bottom-nav bar-standard bar-footer">
            <a class="tab-item external" href="<?php echo U('Index/index');?>">
                <span class="icon"><img src="/Public/Api/images/icon-home.png" alt=""></span>
                <span class="tab-label">首页</span>
            </a>
            <a class="tab-item external active" href="#">
                <span class="icon icon-me1"><img src="/Public/Api/images/icon-news1.png" alt=""></span>
                <span class="tab-label">订单</span>
            </a>
            <a class="tab-item external" href="<?php echo U('User/index');?>">
                <span class="icon"><img src="/Public/Api/images/icon-user.png" alt=""></span>
                <span class="tab-label">我的</span>
            </a>
        </nav>
        <div class="content">
            <div class="buttons-tab">
                <a href="#tab_1" onclick="changeTab(this);" class="tab-link button <?php if($type == 0): ?>active<?php endif; ?>">等待中</a>
                <a href="#tab_2" onclick="changeTab(this);" class="tab-link button <?php if($type == 2): ?>active<?php endif; ?>">服务中</a>
                <a href="#tab_3" onclick="changeTab(this);" class="tab-link button <?php if($type == 3): ?>active<?php endif; ?>">待支付</a>
                <a href="#tab_4" onclick="changeTab(this);" class="tab-link button <?php if($type == 4): ?>active<?php endif; ?>">历史订单</a>
                <input type="hidden" name="lastIndex" id="lastIndex" value="0"/>
                <input type="hidden" name="tabIndex" id="tabIndex" value="<?php echo ($type); ?>"/>
            </div>
            <div class="content-block">
                <div class="tabs">
                    <!--等待中-->
                    <div id="tab_1" class="tab active infinite-scroll">
                    	<div class="fff">
                        </div>
                        <div class="infinite-scroll-preloader">
							<div class="preloader">
	                      	</div>
	                    </div>
                    </div>
                    <!--等待中-->
                    <div id="tab_2" class="tab infinite-scroll">
                    	<div class="fff">
                    	</div>
                    	<div class="infinite-scroll-preloader">
							<div class="preloader">
	                      	</div>
	                    </div>
                    </div>
                    <!--等待中-->
                    <div id="tab_3" class="tab infinite-scroll">
                    	<div class="fff">
                    	</div>
                    	<div class="infinite-scroll-preloader">
							<div class="preloader">
	                      	</div>
	                    </div>
                    </div>
                    <!--等待中-->
                    <div id="tab_4" class="tab infinite-scroll">
                    	<div class="fff">
                    	</div>
                    	<div class="infinite-scroll-preloader">
							<div class="preloader">
	                      	</div>
	                    </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>




	<!-- 底部
================================================== -->
<footer>
</footer>
<script type="text/javascript">
    (function(){
        var ThinkPHP = window.Think = {
            "ROOT"   : "", //当前网站地址
            "APP"    : "/api.php?s=", //当前项目地址
            "PUBLIC" : "/Public", //项目公共目录地址
            "DEEP"   : "<?php echo C('URL_PATHINFO_DEPR');?>", //PATHINFO分割符
            "MODEL"  : ["<?php echo C('URL_MODEL');?>", "<?php echo C('URL_CASE_INSENSITIVE');?>", "<?php echo C('URL_HTML_SUFFIX');?>"],
            "VAR"    : ["<?php echo C('VAR_MODULE');?>", "<?php echo C('VAR_CONTROLLER');?>", "<?php echo C('VAR_ACTION');?>"]
        }
    })();
    
</script>
<script src="/Public/Api/js/zepto.min.js" type="text/javascript">
</script>
<script type="text/javascript">
//坑死人的配置项
//若不加此配置，则所有页面均使用 js 和 css 缓存
$.config = {
   	router: false
}
</script>
<script src="/Public/Api/js/sm.min.js" type="text/javascript">
</script>
<script src="/Public/Api/js/sm-extend.min.js" type="text/javascript">
</script>
<script src="/Public/Api/js/think.js" type="text/javascript">
</script>


<script type="text/javascript">

var target = Think.U('Orders/ajax_orderList');
var params = ['lastIndex', 'tabIndex'];
var container = '.infinite-scroll.active .fff';

$("#lastIndex").val('0');

var tb = $("#tabIndex").val();
tb = tb ? tb : '1';
$("a[class*='tab-link']").removeClass('active');
$("div[id^='tab_']").removeClass('active');
$("a[class*='tab-link']").eq(tb-1).addClass('active');
$("div[id^='tab_']").eq(tb-1).addClass('active');

function changeTab(obj){
	
	var tabHref = $.trim($(obj).attr('href'));
	var index = tabHref.indexOf('_');
	var tabIndex = tabHref.substr(index+1);

	if(!isNaN(tabIndex)){
		
		$("#tabIndex").val(tabIndex);

		if($("#tab_" + tabIndex).find('.infinite-scroll-preloader').css("display")==='block'){
			
			var itemLength = $("#tab_" + tabIndex).find('.content-block').length;

			$("#lastIndex").val(itemLength);
			$.init();
			
			if(itemLength == 0){
				addItems();
			}
		}
	}
}

function joinHTML(data){
	
	var html = '';

	if($.isArray(data) && data.length > 0){
		
		var idStr = $('.infinite-scroll.active').attr('id');
		var tabIndex = '1';
		var status = '等待接单';
		
		if(idStr){
			var index = idStr.indexOf('_');
			tabIndex = idStr.substr(index+1);
		}
		
		if(tabIndex == 2){
			status = '正在处理';
		}else if(tabIndex == 3){
			status = '待支付';
		}else if(tabIndex == 4){
			status = '已完成';
		}
		
		$.each(data, function(key, val){
			
			var serviceTime = 0;
			
			if(val['emergency'] == 2){
				var delay = val['delay'] ? val['delay'] : '50';
				serviceTime = delay + '分钟';
			}else{
				serviceTime = formatTime(val['appointment']);
			}

			var click = 'onclick="javascript:window.location.href=\'<?php echo U("Orders/viewDetail", '', '');?>/order_id/' + val['order_id']+'.html\'"';
			
			if(tabIndex == 3 || tabIndex == 4){
				
				var paybtn = '';
				status = '';
				
				if(val['status'] == 4){
					status = '待支付';
					paybtn = '<a class="right pay" data-no-cache="true" href="<?php echo U("WeChatApi/jsApiCall", '', '');?>/order_id/' + val['order_id']+'.html">支付</a>';
				}else if(val['status'] == 5){
					status = '现金支付待确认';
				}else if(val['status'] == 6){
					status = '待评价';
					paybtn = '<a class="right pay" data-no-cache="true" href="<?php echo U("Worker/comment", '', '');?>/order_id/' + val['order_id']+'.html">评价</a>';
				}else if(val['status'] == 7){
					status = '退单完成';
				}
				
				html += '<div class="content-block"' + click + '><div class="order-list"><div class="clearfix order1 order3">';
				html += '<div class="order-pay-line"><span class="left">下单时间  :</span><div class="order-details clearfix">';
				html += '<span class="order-time left">' + formatTime(val['create_time']) + '</span>';
				html += '<div class="order-state right">' + status + '</div></div></div>';
				html += '<div class="clearfix order-pay"><div class="left"><p>订单编号：<span class="service-category">' + val['order_no'];
				html += '</span></p></div></div><div class="clearfix order-pay">';
				html += '<div class="left"><p>预约时间：<span class="service-time">' + serviceTime + '</span></p>';
				html += '<p>服务类别：<span class="service-category">' + val['detail_name'] + '</span></p></div>';
				html += paybtn + '</div></div></div></div>';
				
			}else{
			
				html += '<div class="content-block" ' + click + '><ul class="order-list"><li class="clearfix order1">';
				html += '<span class="left">下单时间  :</span><div class="order-details"><span class="order-time left">&nbsp;&nbsp;';
				html += formatTime(val['create_time']) + '</span><div class="order-state right">' + status + '</div></div></li>';
				html += '<li>订单编号：<span class="service-time">' + val['order_no'] + '</span></li>';
				html += '<li>预约时间：<span class="service-time">' + serviceTime + '</span></li>';
				html += '<li>服务类别：<span class="service-category">' + val['detail_name'] + '</span></li></ul></div>';
			}
		});
	}else{
		
		html = '<div class="content-block place-order"><p>您还没有相关订单</p>';
		html += '<a href="<?php echo U("Class/viewAction");?>">去下单</a></div>';
	}

	return html;
}

</script>
<script src="/Public/Api/js/pageLoading.js" type="text/javascript"></script>

<!-- 用于加载js代码 -->

</body>
</html>